package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {

    //根据openid查询用户
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);

    //新增用户
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into user values (null, #{openid}, #{name}, #{phone}, #{sex}, #{idNumber}, #{avatar}, #{createTime})")
    void insert(User user);

    //根据主键查询用户
    @Select("select * from user where id = #{id}")
    User getById(Long id);
}
